<?php

namespace app\shop\controller\company;
use app\shop\controller\Controller;
use app\shop\model\company\Company as CompanyModel;

/**
 * 公司介绍
 */
class Company extends Controller
{
    /**
     * 公司介绍
     */
    public function index()
    {
        $app_id = $this->store['app']['app_id'];
        $info = CompanyModel::find($app_id);
        return $this->renderSuccess('', $info);
    }

    public function save()
    {
        try {
            $app_id = $this->store['app']['app_id'];
            $data = input();
            $company = CompanyModel::find($app_id);
            if ($company) {
                $company->save($data);
            } else {
                $data['app_id'] = $app_id;
                CompanyModel::create($data);
            }
            return $this->renderSuccess('保存成功');
        } catch (\Exception $e) {
            return $this->renderError($e->getMessage());
        }
    }
}